//
//  ViewController.swift
//  命令设计模式
//
//  Created by slience on 2019/11/13.
//  Copyright © 2019 shehuiren. All rights reserved.
//

import UIKit

//将一组行为抽象为对象，实现二者之间的松耦合，这就是命令模式

class ViewController: UIViewController {

     let zhrecive = ZHReceiver()
    var dark : CommandProtocol2?
    var light : CommandProtocol2?
    override func viewDidLoad() {
        super.viewDidLoad()
        
//        let recive = Receiver()
//        recive.receiverView = view
//        recive.alpha = 0
//        let obj =  LightObj(receiver: recive, paramter: 0.1)
//        let invoker = Invoker()
//        invoker.addExecte(command: obj)
        
        
         zhrecive.client = self.view
    }
    
    //MARK: - -添加
    @IBAction func addExecte(sender:Any){
        
        dark = MakeDarkCommand(rec: zhrecive, paramter: 0.1)
        
        ZHInvoker.shareInstance.addExcute(command: dark!)
        
       
        
    }
    //MARK: - -删除
    @IBAction func delExecte(sender :Any){
           
        light = MakeLightCommand(rec: zhrecive, paramter: 0.1)
               
               ZHInvoker.shareInstance.addExcute(command: light!)
               
       }
    //MARK: - -返回
    @IBAction func rollBack(sender:Any){
           
            
        ZHInvoker.shareInstance.rollBack()
       }
    
    func test(){
        
       
        
        
        
        
    }
    
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        
        
    }


}

